/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package czStvDpds.graphics3D.geometry;

import java.nio.FloatBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL14;

/**
 * Objekt reprezentující nastavení textury
 *
 * @author divad
 */
public class TextureProperties {

    public static final int FORMAT_RGB = GL11.GL_RGB, FORMAT_RGBA = GL11.GL_RGBA, FORMAT_DEPTH = GL11.GL_DEPTH_COMPONENT, FORMAT_ALPHA = GL11.GL_ALPHA, FORMAT_LUMINACE = GL11.GL_LUMINANCE;
    public static final int TEXTURE_2D = GL11.GL_TEXTURE_2D, TEXTURE_3D = GL12.GL_TEXTURE_3D, TEXTURE_1D = GL11.GL_TEXTURE_1D, TEXTURE_CUBE_MAP = GL13.GL_TEXTURE_CUBE_MAP;
    public static final int FILTER_NEAREST = GL11.GL_NEAREST, FILTER_LINEAR = GL11.GL_LINEAR, FILTER_NEAREST_MIPMAP_NEAREST = GL11.GL_NEAREST_MIPMAP_NEAREST, FILTER_LINEAR_MIPMAP_NEAREST = GL11.GL_LINEAR_MIPMAP_NEAREST, FILTER_NEAREST_MIPMAP_LINEAR = GL11.GL_NEAREST_MIPMAP_LINEAR, FILTER_LINEAR_MIPMAP_LINEAR = GL11.GL_LINEAR_MIPMAP_LINEAR;
    public static final int WRAP_CLAMP_TO_EDGE = GL12.GL_CLAMP_TO_EDGE, WRAP_CAMP_TO_BORDER = GL13.GL_CLAMP_TO_BORDER, WRAP_REPEAT = GL11.GL_REPEAT, WRAP_MIRRORED_REPEAT = GL14.GL_MIRRORED_REPEAT;
    public static final int TEXGEN_OBJECT_LINEAR = GL11.GL_OBJECT_LINEAR, TEXGEN_EYE_LINEAR = GL11.GL_EYE_LINEAR, TEXGEN_SPHERE_MAP = GL11.GL_SPHERE_MAP, TEXGEN_REFLECTION_MAP = GL13.GL_REFLECTION_MAP, TEXGEN_NORMAL_MAP = GL13.GL_NORMAL_MAP;
    public static final int COMPARE_EQUAL = GL11.GL_EQUAL, COMPARE_LEQUAL = GL11.GL_LEQUAL, COMPARE_GEQUAL = GL11.GL_GEQUAL, COMPARE_NOTEQUAL = GL11.GL_NOTEQUAL, COMPARE_GREATER = GL11.GL_GREATER, COMPARE_LESS = GL11.GL_LESS, COMPARE_ALWAYS = GL11.GL_ALWAYS, COMPARE_NEVER = GL11.GL_NEVER;
    private int type = TextureProperties.TEXTURE_2D;
    private int format = TextureProperties.FORMAT_RGBA;
    private int wrapS = TextureProperties.WRAP_REPEAT;
    private int wrapT = TextureProperties.WRAP_REPEAT;
    private int wrapR = TextureProperties.WRAP_REPEAT;
    private int texGenSType = TextureProperties.TEXGEN_EYE_LINEAR;
    private int texGenTType = TextureProperties.TEXGEN_EYE_LINEAR;
    private int texGenRType = TextureProperties.TEXGEN_EYE_LINEAR;
    private int texGenQType = TextureProperties.TEXGEN_EYE_LINEAR;
    private int filterMin = TextureProperties.FILTER_LINEAR;
    private int filterMax = TextureProperties.FILTER_LINEAR;
    private boolean sTexgenEnabled = false;
    private boolean tTexgenEnabled = false;
    private boolean rTexgenEnabled = false;
    private boolean qTexgenEnabled = false;
    private int width = 1;
    private int height = 1;
    private int depth = 1;
    private FloatBuffer texGenSPlane;
    private FloatBuffer texGenTPlane;
    private FloatBuffer texGenRPlane;
    private FloatBuffer texGenQPlane;
    private boolean compare = false;
    private int compareFunction = TextureProperties.COMPARE_ALWAYS;

    public TextureProperties() {
        texGenSPlane = BufferUtils.createFloatBuffer(4);
        texGenTPlane = BufferUtils.createFloatBuffer(4);
        texGenRPlane = BufferUtils.createFloatBuffer(4);

        texGenSPlane.put(new float[]{1, 0, 0, 0});
        texGenTPlane.put(new float[]{0, 1, 0, 0});
        texGenRPlane.put(new float[]{0, 0, 1, 0});

        texGenSPlane.rewind();
        texGenTPlane.rewind();
        texGenRPlane.rewind();
    }

    public TextureProperties(TextureProperties properties) {
        if (properties != null) {
            this.setCompare(properties.isCompare());
            this.setCompareFunction(properties.getCompareFunction());
            this.setDepth(properties.getDepth());
            this.setFilterMax(properties.getFilterMax());
            this.setFilterMin(properties.getFilterMin());
            this.setFormat(properties.getFormat());
            this.setHeight(properties.getHeight());
            this.setTexGenQPlane(properties.getTexGenQPlane());
            this.setTexGenQType(properties.getTexGenQType());
            this.setTexGenRPlane(properties.getTexGenRPlane());
            this.setTexGenRType(properties.getTexGenRType());
            this.setTexGenSPlane(properties.getTexGenSPlane());
            this.setTexGenSType(properties.getTexGenSType());
            this.setTexGenTPlane(properties.getTexGenTPlane());
            this.setTexGenTType(properties.getTexGenTType());
            this.setType(properties.getType());
            this.setWidth(properties.getWidth());
            this.setWrapR(properties.getWrapR());
            this.setWrapS(properties.getWrapS());
            this.setWrapT(properties.getWrapT());
            this.setqTexgenEnabled(properties.isqTexgenEnabled());
            this.setrTexgenEnabled(properties.isrTexgenEnabled());
            this.setsTexgenEnabled(properties.issTexgenEnabled());
            this.settTexgenEnabled(properties.istTexgenEnabled());
        } else {
            texGenSPlane = BufferUtils.createFloatBuffer(4);
            texGenTPlane = BufferUtils.createFloatBuffer(4);
            texGenRPlane = BufferUtils.createFloatBuffer(4);

            texGenSPlane.put(new float[]{1, 0, 0, 0});
            texGenTPlane.put(new float[]{0, 1, 0, 0});
            texGenRPlane.put(new float[]{0, 0, 1, 0});

            texGenSPlane.rewind();
            texGenTPlane.rewind();
            texGenRPlane.rewind();
        }
    }

    public int getDepth() {
        return depth;
    }

    public int getHeight() {
        return height;
    }

    public boolean isrTexgenEnabled() {
        return rTexgenEnabled;
    }

    public boolean issTexgenEnabled() {
        return sTexgenEnabled;
    }

    public boolean istTexgenEnabled() {
        return tTexgenEnabled;
    }

    public boolean isqTexgenEnabled() {
        return qTexgenEnabled;
    }

    public int getTexGenRType() {
        return texGenRType;
    }

    public int getTexGenSType() {
        return texGenSType;
    }

    public int getTexGenTType() {
        return texGenTType;
    }

    public int getTexGenQType() {
        return texGenQType;
    }

    public int getType() {
        return type;
    }

    public int getFormat() {
        return format;
    }

    public int getWidth() {
        return width;
    }

    public int getWrapR() {
        return wrapR;
    }

    public int getWrapS() {
        return wrapS;
    }

    public int getWrapT() {
        return wrapT;
    }

    public int getFilterMax() {
        return filterMax;
    }

    public int getFilterMin() {
        return filterMin;
    }

    public FloatBuffer getTexGenRPlane() {
        return texGenRPlane;
    }

    public FloatBuffer getTexGenSPlane() {
        return texGenSPlane;
    }

    public FloatBuffer getTexGenTPlane() {
        return texGenTPlane;
    }

    public FloatBuffer getTexGenQPlane() {
        return texGenQPlane;
    }

    public boolean isCompare() {
        return compare;
    }

    public int getCompareFunction() {
        return compareFunction;
    }
    ///////////////////////////////////////////////////////////////////

    public void setDepth(int depth) {
        this.depth = depth;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public void setrTexgenEnabled(boolean rTexgenEnabled) {
        this.rTexgenEnabled = rTexgenEnabled;
    }

    public void setsTexgenEnabled(boolean sTexgenEnabled) {
        this.sTexgenEnabled = sTexgenEnabled;
    }

    public void settTexgenEnabled(boolean tTexgenEnabled) {
        this.tTexgenEnabled = tTexgenEnabled;
    }

    public void setqTexgenEnabled(boolean qTexgenEnabled) {
        this.qTexgenEnabled = qTexgenEnabled;
    }

    public void setTexGenRType(int texgGenRType) {
        this.texGenRType = texgGenRType;
    }

    public void setTexGenSType(int texGenSType) {
        this.texGenSType = texGenSType;
    }

    public void setTexGenTType(int texGenTType) {
        this.texGenTType = texGenTType;
    }

    public void setTexGenQType(int texGenQType) {
        this.texGenQType = texGenQType;
    }

    public void setType(int type) {
        this.type = type;
    }

    public void setFormat(int format) {
        this.format = format;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public void setWrapR(int wrapR) {
        this.wrapR = wrapR;
    }

    public void setWrapS(int wrapS) {
        this.wrapS = wrapS;
    }

    public void setWrapT(int wrapT) {
        this.wrapT = wrapT;
    }

    public void setFilterMax(int filterMax) {
        this.filterMax = filterMax;
    }

    public void setFilterMin(int filterMin) {
        this.filterMin = filterMin;
    }

    public void setTexGenRPlane(FloatBuffer texGenRPlane) {
        this.texGenRPlane = texGenRPlane;
    }

    public void setTexGenSPlane(FloatBuffer texGenSPlane) {
        this.texGenSPlane = texGenSPlane;
    }

    public void setTexGenTPlane(FloatBuffer texGenTPlane) {
        this.texGenTPlane = texGenTPlane;
    }

    public void setTexGenQPlane(FloatBuffer texGenQPlane) {
        this.texGenQPlane = texGenQPlane;
    }

    public void setCompare(boolean compare) {
        this.compare = compare;
    }

    public void setCompareFunction(int compareFunction) {
        this.compareFunction = compareFunction;
    }
}
